library RiflemanTraining initializer init

	private function Trig_Reload_Time_Reduction_Conditions takes nothing returns boolean
		return GetLearnedSkill() == 'A07V'
	endfunction

	private function Trig_Reload_Time_Reduction_Actions takes nothing returns nothing
		local unit u = GetTriggerUnit()
		local integer level = GetUnitAbilityLevel(u, 'A07V') 
		local player p = GetOwningPlayer(u)
		local integer id = GetConvertedPlayerId(p)  
		
		if level == 1 then
			// unlock ballistics
			call SetPlayerTechResearched(p, 'R013', level)
		endif
		
		if( level == 2 ) then 
			// unlock reload
			set udg_ReloadTime[id] = 2.50
			call SetPlayerTechResearched(p, 'R013', level)
		endif
		
		if( level == 3 ) then 
			// unlock reload aware icon
			// handled in the reload system for now
			call SetPlayerTechResearched(p, 'R013', level)
		endif
		
		if( level == 4 ) then 
			// unlock smoke grenade
			call SetPlayerTechResearched(p, 'R013', level)
		endif
	
		if( level == 5) then 
			// unlock smoke grenade
			call SetPlayerTechResearched(p, 'R013', level)
			call SetUnitAbilityLevel(u, 'A08R', 2)
		endif
		
		set u = null
		set p = null

	endfunction

	private function init takes nothing returns nothing
		local trigger t
		set t = CreateTrigger(  )
		call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
		call TriggerAddCondition( t, Condition( function Trig_Reload_Time_Reduction_Conditions ) )
		call TriggerAddAction( t, function Trig_Reload_Time_Reduction_Actions )
	endfunction

endlibrary